<!--
**
**tabbar组件
**
-->
<template>
  <div class="cc">
    <div class="mask" v-show="show">
      <div class="mask-item" @click="goshouye()">
        <div class="mask-img">
          <!-- <img src="../../assets/img/main/shouye.png" alt=""> -->
        </div>
        <div class="mask-title">首页</div>
      </div>
      <div class="mask-item1" @click="godingdan()">
        <div class="mask-img1">
          <!-- <img src="../../assets/img/main/ddjl.png" alt=""> -->
        </div>
        <div class="mask-title1">订单记录</div>
      </div>
      <div class="mask-item2" @click="gomine()">
        <div class="mask-img2">
          <!-- <img src="../../assets/img/main/grzx.png" alt=""> -->
        </div>
        <div class="mask-title2">个人中心</div>
      </div>
    </div>
    <div class="allbtn" @click="change()">
      <img src="../../assets/img/main/geren.png" alt="" />
    </div>
  </div>
</template>

<script>
import { TABTYPE } from "@u/wordbook";
import Vue from "vue";
import { Tabbar, TabbarItem } from "vant";
import { Dialog } from "vant";
Vue.use(Tabbar);
Vue.use(TabbarItem);
export default {
  name: "tabBar",
  data() {
    return {
      show: false
    };
  },
  mounted() {},
  methods: {
    //去首页
    goshouye() {
      this.$router.replace({
        name: "Home"
      });
      this.show = false;
    },
    //去订单页面
    godingdan() {
      let token = localStorage.getItem("token");
      if (token) {
        this.show = false;

        this.$router.replace({
          path: "/medicalRecord"
        });
      } else {
        Dialog.confirm({
          title: "提示",
          message: "需前往登录页面完成登录"
        })
          .then(() => {
            this.$router.push({
              name: "login"
            });
            // on confirm
          })
          .catch(() => {
            // on cancel
          });
      }
    },
    //样式切换
    change() {
      if (this.show == false) {
        this.show = true;
      } else {
        this.show = false;
      }
    },
    //去首页
    gomine() {
      let token = localStorage.getItem("token");
      if (token) {
        this.$router.replace({
          name: "Mine"
        });
      } else {
        Dialog.confirm({
          title: "提示",
          message: "需前往登录页面完成登录"
        })
          .then(() => {
            this.$router.push({
              name: "login"
            });
            // on confirm
          })
          .catch(() => {
            // on cancel
          });
      }
      this.show = false;
    }
  }
};
</script>

<style lang="scss" scoped>
.cc {
  width: 100%;
}
.mask {
  position: fixed;
  bottom: 2.8rem;
  right: calc(50% - 4.5rem);
  width: 3.2rem;
  background: #000000;
  opacity: 0.65;
  border-radius: 0.1rem;
  padding-bottom: 0.4rem;
  .mask-item {
    width: 80%;
    margin-left: 0.4rem;
    margin-top: 0.1rem;
    display: flex;
    height: 0.8rem;
    .mask-img {
      width: 0.5rem;
      height: 0.5rem;
      margin-top: 0.3rem;
      background: url(../../assets/img/main/shouye.png) no-repeat;
      background-size: cover;
      margin-right: 0.2rem;
    }
    .mask-title {
      margin-top: 0.3rem;
      font-size: 0.42rem;
      font-family: Source Han Sans CN;
      font-weight: 400;
      color: #ffffff;
    }
  }
  .mask-item1 {
    width: 80%;
    margin-left: 0.4rem;
    margin-top: 0.1rem;
    display: flex;
    height: 0.8rem;
    .mask-img1 {
      width: 0.5rem;
      height: 0.5rem;
      margin-top: 0.3rem;
      background: url(../../assets/img/main/ddjl.png) no-repeat;
      background-size: cover;
      margin-right: 0.2rem;
    }
    .mask-title1 {
      margin-top: 0.3rem;
      font-size: 0.42rem;
      font-family: Source Han Sans CN;
      font-weight: 400;
      color: #ffffff;
    }
  }
  .mask-item2 {
    width: 80%;
    margin-left: 0.4rem;
    margin-top: 0.1rem;
    display: flex;
    height: 0.8rem;
    .mask-img2 {
      width: 0.5rem;
      height: 0.5rem;
      margin-top: 0.3rem;
      background: url(../../assets/img/main/grzx.png) no-repeat;
      background-size: cover;
      margin-right: 0.2rem;
    }
    .mask-title2 {
      margin-top: 0.3rem;
      font-size: 0.42rem;
      font-family: Source Han Sans CN;
      font-weight: 400;
      color: #ffffff;
    }
  }
}
.allbtn {
  width: 1.5rem;
  height: 1.5rem;
  position: fixed;
  bottom: 1rem;
  right: calc(50% - 4.5rem);
  background-color: #07c6b4;
  box-shadow: black;
  border-radius: 50%;
  text-align: center;

  img {
    width: 50%;
    height: 50%;
    position: absolute;
    top: 25%;
    left: 25%;
  }
}
</style>
